#define _CRT_SECURE_NO_WARNINGS 1

#include "Sort.h"

void TestPerformance();

int main() {
	//TestPerformance();
	int arr[] = { 1, 6, 2, 8996, 10, -1 };
	int ret[2];
	max(arr, sizeof arr / sizeof arr[0]);
}

void TestPerformance() {
	const int N = 5000000;
	//int* a1 = (int*)malloc(sizeof(int) * N);
	//int* a2 = (int*)malloc(sizeof(int) * N);
	//int* a3 = (int*)malloc(sizeof(int) * N);
	//int* a4 = (int*)malloc(sizeof(int) * N);
	//int* a5 = (int*)malloc(sizeof(int) * N);
	int* a6 = (int*)malloc(sizeof(int) * N);
	int* a10 = (int*)malloc(sizeof(int) * N);
	int* a11 = (int*)malloc(sizeof(int) * N);
	int* a12 = (int*)malloc(sizeof(int) * N);
	int* a13 = (int*)malloc(sizeof(int) * N);
	int* a14 = (int*)malloc(sizeof(int) * N);
	int* a15 = (int*)malloc(sizeof(int) * N);

	srand((unsigned int)time(0));
	for (int i = 0; i < N; i++) {
		//a1[i] = rand();
		//a2[i] = a1[i];
		//a3[i] = a1[i];
		//a4[i] = a1[i];
		//a5[i] = a1[i];
		a6[i] = rand();
		a10[i] = a6[i];
		a11[i] = a6[i];
		a12[i] = a6[i];
		a13[i] = a6[i];
		a14[i] = a6[i];
		a15[i] = a6[i];
	}

	//int begin1 = clock();
	//BubbleSort(a1, N);
	//int end1 = clock();

	//int begin2 = clock();
	//InsertionSort(a2, N);
	//int end2 = clock();

	//int begin3 = clock();
	//ShellSort(a3, N);
	//int end3 = clock();

	//int begin4 = clock();
	//SelectionSort(a4, N);
	//int end4 = clock();

	//int begin5 = clock();
	//HeapSort(a5, N);
	//int end5 = clock();

	int begin6 = clock();
	QuickSort1(a6, 0, N - 1);
	int end6 = clock();

	int begin10 = clock();
	QuickSort2(a10, 0, N - 1);
	int end10 = clock();

	int begin11 = clock();
	QuickSort3(a11, 0, N - 1);
	int end11 = clock();

	int begin12 = clock();
	QuickSortNonRecur(a12, 0, N - 1);
	int end12 = clock();

	int begin13 = clock();
	MergeSort(a13, 0, N - 1);
	int end13 = clock();

	int begin14 = clock();
	MergeSortNonRecur(a14, N);
	int end14 = clock();

	int begin15 = clock();
	CountSort(a15, N);
	int end15 = clock();

	//printf("BubbleSort: %d\n", end1 - begin1);
	//printf("InsertionSort: %d\n", end2 - begin2);
	//printf("ShellSort: %d\n", end3 - begin3);
	//printf("SelectionSort: %d\n", end4 - begin4);
	//printf("HeapSort: %d\n", end5 - begin5);
	printf("QuickSort1: %d\n", end6 - begin6);
	printf("QuickSort2: %d\n", end10 - begin10);
	printf("QuickSort3: %d\n", end11 - begin11);
	printf("QuickSortNonRecur: %d\n", end12 - begin12);
	printf("MergeSort: %d\n", end13 - begin13);
	printf("MergeSortNonRecur: %d\n", end14 - begin14);
	printf("CountSort: %d\n", end15 - begin15);
}
